import fetch from "@/common/fetch";

//============用户管理=============
/**
 * 管理后台登录
 */

export const adminLogin = data => fetch("/api/adminLogin", data, "POST");

/**
 * 退出
 */

export const signout = () => fetch("/api/adminSingout");

/**
 *  list
 */

export const userList = () => fetch("/api/userList");

/**
 *  userUpdate
 */

export const userUpdate = data => fetch("/api/userUpdate", data, "POST");

/**
 *  userDelete
 */

export const userDelete = data => fetch("/api/userDelete", data, "POST");

/**
 *  userCreate
 */

export const userCreate = data => fetch("/api/userCreate", data, "POST");
//============词条=============

/**
 * 获取某条词条
 */

export const langItemDetail = id => fetch("/api/langItem/" + id);

/**
 * 获取某个项目的词条 必填: projID ,其他 keyword(搜索) ,page ,pagesize
 */

export const langItemList = data => fetch("/api/langItemList", data);

/**
 * 创建
 */
export const langItemCreate = data =>
  fetch("/api/langItemCreate", data, "POST");

/**
 * 更新
 */
export const langItemUpdate = data =>
  fetch("/api/langItemUpdate?" + "projID=" + data.projID, data, "POST");

/**
 * 删除
 */
export const langItemDelete = data =>
  fetch("/api/langItemDelete?" + "projID=" + data.projID, data, "POST");

//============项目管理=============

export const projList = () => fetch("/api/projList");

/**
 * 创建
 */
export const projCreate = data => fetch("/api/projCreate", data, "POST");

/**
 * 更新
 */
export const projUpdate = data => fetch("/api/projUpdate", data, "POST");

/**
 * 删除
 */
export const projDelete = data => fetch("/api/projDelete", data, "POST");

//============其他=============
/**
 * 通用排序
 */

export const generalSort = data => fetch("/api/general/sort", data, "POST");

/**
 * 导出下载语言文件
 */

export const exportLangfile = platform => fetch("/api/exportLang/" + platform);

/**
 * 导出下载语言文件(极简) , 参数分别是平台,项目ID,导出的语言设置 {langs:导出语言标识符数组}
 */

export const exportLangItems = (platform, projID, data) =>
  fetch("/api/exportLangItems/" + platform + "/" + projID, data, "POST");
